<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>bot登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">QQ</label>
                <div class="layui-input-block">
                    <input type="number" name="qq" lay-verify="required" lay-reqtext="QQ不能为空" placeholder="请输入QQ号"  value="3389755300" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">密码</label>
                <div class="layui-input-block">
                    <input type="text" name="passwrod" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码"  value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">登录</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['jquery','form','miniTab','layer'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;
        form.on('submit(saveBtn)', function (data) {
            var json = data.field;
            var test_i;
            $.ajax({
                url: '/AddBot',
                type: 'POST',
                async: true,
                cache: false,
                data: "qq="+json.qq+"&passwrod="+json.passwrod,
                beforeSend: function () {
                    test_i=showLoad();
                },
                success: function (dt) {
                    closeLoad(test_i);
                    if(dt.msg==="登录成功！"){
                        localStorage.setItem("bot_qq",json.qq);
                        $(".layuimini-logo a img").attr("src", "http://q1.qlogo.cn/g?b=qq&nk="+json.qq+"&s=100");
                    }
                    var index = layer.alert(dt.msg, {
                        title: '提示'
                    }, function () {
                        layer.close(index);
                        window.parent.location="/admin";
                    });
                }
            })
            return false;
        });
        function showLoad() {
            return layer.msg('玩命登录中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: 'auto', time:100000});
        }
        function closeLoad(index) {
            layer.close(index);
        }
    });
</script>
</body>
</html>